//
//  VideoCell.m
//  qiuShiJiangHu
//
//  Created by xalo on 16/1/25.
//  Copyright © 2016年 糗事江湖项目组. All rights reserved.
//

#import "VideoCell.h"
#import "VideoModel.h"
#import "UIImageView+WebCache.h"

@interface VideoCell ()

@property (strong, nonatomic) IBOutlet UIImageView *iconImage;

@property (strong, nonatomic) IBOutlet UILabel *loginLabel;

@property (strong, nonatomic) IBOutlet UILabel *laughLabel;

@property (strong, nonatomic) IBOutlet UILabel *commentLabel;

@property (strong, nonatomic) IBOutlet UILabel *shareLabel;

@property (strong, nonatomic) IBOutlet UIButton *laughButton;

@property (strong, nonatomic) IBOutlet UIButton *unlaughButton;





@end



@implementation VideoCell

-(void)setContentViewWithModel:(VideoModel *)model
{
    self.loginLabel.text = model.login;
    
    self.contentLabel.text = model.content;
    
    NSInteger number = model.Id;
    
    NSString *numStr = [NSString stringWithFormat:@"%ld",number];
    
    NSString *num1 = nil;
    
    if (numStr.length == 8) {
        
        num1 = [numStr substringWithRange:NSMakeRange(0, 4)];
        
    }else if(numStr.length == 7)
    {
        num1 = [numStr substringWithRange:NSMakeRange(0, 3)];
        
    }else if(numStr.length == 6)
    {
        num1 = [numStr substringWithRange:NSMakeRange(0, 2)];
        
    }else
    {
        num1 = [numStr substringWithRange:NSMakeRange(0, 1)];
        
    }    
    NSString *url = [NSString stringWithFormat:@"http://pic.qiushibaike.com/system/avtnew/%@/%@/thumb/%@",num1,numStr,model.icon];
    
    [self.iconImage sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"Icon@2x"]];
    self.iconImage.layer.cornerRadius = 18;
    
    self.iconImage.layer.masksToBounds = YES;
    
    
    [self.contentImage sd_setImageWithURL:[NSURL URLWithString:model.pic_url] placeholderImage:[UIImage imageNamed:@"Icon@2x"]];
    
    self.laughLabel.text=[NSString stringWithFormat:@"%@",model.votes[@"up"]];
    
    self.commentLabel.text=[NSString stringWithFormat:@"%ld",model.comments_count];
    
    self.shareLabel.text=[NSString stringWithFormat:@"%ld",model.share_count];
    
}


- (IBAction)clickButtonWithUrl:(UIButton *)sender {
    

        

    
    

}








- (IBAction)clickLaughButton:(UIButton *)sender {
    
    NSInteger number = [self.laughLabel.text integerValue];
    
    number++;
    
    self.laughLabel.text = [NSString stringWithFormat:@"%ld",number];

    
    
}


- (IBAction)clickUnlaughButton:(UIButton *)sender {
    
    NSInteger number = [self.laughLabel.text integerValue];
    
    number--;
    
    self.laughLabel.text = [NSString stringWithFormat:@"%ld",number];

    
}







- (void)awakeFromNib {
   
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
